<?php

/**
 * sfExcelReaderExample actions.
 *
 * @package     sfExcelReaderPlugin
 * @author      Tomasz Ducin <tomasz.ducin@gmail.com>
 */

class sfExcelReaderExampleActions extends sfActions
{
  /**
   * Demo action. Interprets and displays an example xls file.
   *
   * @param sfRequest $request A request object
   */
  public function executeIndex(sfWebRequest $request)
  {
     

    //$this->root_dir=sfConfig::get('sf_root_dir');
    //error_reporting(E_ALL ^ E_NOTICE);
    
    //$this->data = new sfExcelReader(sfConfig::get('sf_root_dir').'/plugins/sfExcelReaderPlugin/data/endesa1.xls');
//    $this->data = new Spreadsheet_Excel_Reader(sfConfig::get('sf_root_dir').'/plugins/sfExcelReaderPlugin/data/endesa1.xls');
//
//     adding default excel reader stylesheet
//    $this->getResponse()->addStylesheet('/sfExcelReaderPlugin/css/excel_reader');
//
//    $this->nombreCompania= $this->data->val(5, 'A');
//    $this->nombreEmpresa= $this->data->val(14, 'H');

//    $this->reader=new Spreadsheet_Excel_Reader();
//    $this->reader->setUTFEncoder('iconv');//    $this->reader->setUTFEncoder('mb');
//    $this->reader->setOutputEncoding('UTF-8'); //    $this->reader->setOutputEncoding("CP-1251");
//    $this->reader->read(sfConfig::get('sf_root_dir').'/plugins/sfExcelReaderPlugin/data/endesa1.xls');
  }

   public function executeSubmit($request)
  {
//    $this->forward404Unless($request->isMethod('post')); //Si no es true, redirige a una página de error.
//    $this->rutaExcel=$request->getParameter('excel');
//
//    $this->data = new Spreadsheet_Excel_Reader(sfConfig::get('sf_root_dir').'/plugins/sfExcelReaderPlugin/data/endesa1.xls');
//    $this->nombreCompania= $this->data->val(5, 'A');
//    $this->nombreEmpresa= $this->data->val(14, 'H');

   // $this->redirect('anadirContrato/new?'.http_build_query($request->getParameter('excel')));
  }
}
